import React from "react";
import { Link, Routes, Route, useParams } from "react-router-dom";

const Home = () => {
  return <div>home组件</div>;
};

class About extends React.Component {
  render() {
    return <div>about组件</div>;
  }
}

const Detail = () => {
  const { id } = useParams();
  return <div>detail页面 - {id}</div>;
};

const App = () => {
  return (
    <>
      <h3>router-v6-动态可选参数</h3>
      <ul>
        <li>
          <Link to="/home">home</Link>
        </li>
        <li>
          <Link to="/about">about</Link>
        </li>
        <li>
          <Link to="/detail/456">detail</Link>
        </li>
      </ul>

      <hr />

      <Routes>
        <Route path="/home" element={<Home />}></Route>
        <Route path="/about" element={<About />}></Route>
        <Route path="/detail" element={<Detail />}>
          <Route path=":id" element={<Detail />}></Route>
        </Route>
      </Routes>
    </>
  );
};

export default App;
